home *** CD-ROM | disk | FTP | other *** search
/ PCMania 30 / PCMania CD30.iso / pcmania / graf30 / tacs / rfldsize.c < prev    next >
C/C++ Source or Header  |  1988-04-27  |  1KB  |  64 lines

  1. #include <tiff.h>
  2.  
  3. extern LONG get_1st_ifd();
  4. extern SHORT type_length();
  5. extern BOOL access_ifd();
  6. extern BOOL read_dir();
  7.  
  8. SHORT
  9. rfield_size(fhandle, fdtype, buffer)
  10. SHORT fhandle;
  11. SHORT fdtype;
  12. FIELD_INFO far *buffer;
  13. {
  14.     LONG ifd_offset = get_1st_ifd(fhandle);
  15.     LONG new_offset;
  16.     TIFF_DIR_ENTRY dirent;
  17.     SHORT entry_count;
  18.     SHORT subfile_type;
  19.     SHORT n;
  20.     LONG tot_size;
  21.  
  22.     /* go through IFD's ... stop at null IFD offset */
  23.     while(ifd_offset)
  24.     {
  25.         /* get pertinent IFD data */
  26.         if(access_ifd(fhandle, ifd_offset,
  27.           (TIFF_DIR_ENTRY far *)&dirent, &entry_count, &subfile_type,
  28.           &new_offset))
  29.         {
  30.             return(0);
  31.         }
  32.  
  33.         /* match on subfile type? */
  34.         if(fdtype == subfile_type)
  35.         {
  36.             n = entry_count - 1;
  37.             tot_size = 0;
  38.  
  39.             /* go through each entry */
  40.             while(n-- > 0 && !read_dir(fhandle,
  41.               (TIFF_DIR_ENTRY far *)&dirent))
  42.             {
  43.                 LONG temp = (LONG)type_length(dirent.type);
  44.                 temp *= dirent.length;
  45.                 tot_size += temp;
  46.                 tot_size += SHORT_SIZE + SHORT_SIZE;
  47.             }
  48.  
  49.             /* if we bombed out early, error exit */
  50.             if(n > 0)
  51.             {
  52.                 return(0);
  53.             }
  54.  
  55.             /* since we matched, we can now go bye-bye */
  56.             buffer->num_tags = entry_count;
  57.             buffer->num_bytes = tot_size;
  58.             return(1);
  59.         }
  60.         ifd_offset = new_offset;
  61.     }
  62.     return(0);
  63. }
  64.